<template>
  <div>
    <div class="bg">
<van-search
  v-model="value"
  show-action
  placeholder="请输入搜索关键词"
  @search="onSearch"
  @cancel="onCancel"
>
</van-search>
</div>
  <van-cell :title="item.communityName"  v-for="(item,index) in  list" :key="index"  @click="itemFn(item)"></van-cell>
  </div>
</template>

<script>
import { cityMessageFn, XiaoQuFn } from '@/api/area'
export default {
  data () {
    return {
      value: '',
      id: '',
      list: []
    }
  },
  methods: {
    async onSearch (name) {
      const res = await cityMessageFn(name)
      this.id = res.body.value
      this.name = res.body.label
      const { body } = await XiaoQuFn(name, this.id)
      console.log(body)
      this.list = body
    },
    onCancel () {
      this.$router.go(-1)
    },
    itemFn (value) {
      console.log(value)
      this.$store.commit('inputname', value)
      this.$router.back()
    }
  }

}
</script>

<style lang="less" scoped>
.bg{
  background-color: #f6f5f6;
  width: 100%;
  height: 63px;
}
.colse{
height: 40px;
  background-color:#f6f5f6 ;
  width: 60px;
 margin-right: -10px;
 text-align: center;

}
</style>
